﻿<MudTreeView T="DocumentedType" Dense="true" Items="@Root" SelectionMode="SelectionMode.SingleSelection" @bind-SelectedValue="@SelectedType">
    <ItemTemplate>
        <MudTreeViewItem T="DocumentedType" Expanded="@context.Expanded" Text="@context.Text" Items="@context.Children" OnClick="@(() => OnTypeClicked(context))">
            <Content>
                @if (context.Value.Name == "Root")
                {
                    <MudIcon Icon="@Icons.Material.Filled.Home" Color="Color.Primary" Class="mr-2" />
                    <MudText Typo="Typo.body2">@context.Text</MudText>
                }
                else
                {
                    <MudTreeViewItemToggleButton @bind-Expanded="@context.Expanded" Visible="@(context.Children.Count > 0)" />

                    @if (context.Value.NameFriendly == Type.NameFriendly)
                    {
                        <MudIcon Icon="@Icons.Custom.Brands.MudBlazor" Color="Color.Primary" Class="mr-2" />
                        <MudText Typo="Typo.body2">@context.Text</MudText>
                    }
                    else if (!string.IsNullOrEmpty(context.Value.ApiUrl))
                    {
                        <MudLink Typo="Typo.body2" Href="@context.Value.ApiUrl">@context.Text</MudLink>
                    }
                }
            </Content>
        </MudTreeViewItem>
    </ItemTemplate>
</MudTreeView>